import { useState,useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
import Mains from '@/views/main/main'
import Login from '@/views/login/Login'
import { useLocation } from 'react-router-dom'
import style from '@/style/scss/app.module.scss'

function App() {
  const navigate = useNavigate()
  const { pathname } = useLocation()

  const data = sessionStorage.getItem('tokenMsg')
  const token = data ? JSON.parse(sessionStorage.tokenMsg) : ''
  
  useEffect(() => {
    !token ? navigate('/login') : navigate('/afeng/home')
  },[])

  

  return (
    <>
      <div className={style.app} style={{ backgroundImage: <Login /> ?  'url("/imgs/sakura.jpg")' : ''}} >
        { !token ? <Login /> : <Mains /> }
      </div>
    </>
  )
}

export default App
